01. Introduction
OOJS L3 1 - Lesson Overview
Properties and Methods
We've been using properties and methods all up to this point, and in the next section you'll bring your knowledge of object-oriented programming to another level of sophistication by creating classes (i.e., categories) of objects!
Since an object can represent data and functionality, we can use an object to express real-life things (i.e., someone or something) in code. You've seen a few one-off examples throughout the course, but now let's take a deeper dive into it!
OOJS L3 3 - Real-Life Objects - UPDATED
Reflect
QUESTION:
Find something around you and create an object of its properties and methods.
ANSWER:
Thanks for taking the time to complete this. Practicing this will help us in the very next section!
OOJS L3 5 - Classification Of Objects V1
Task Description:
Now it's your turn! Take some time to look around your area for objects and reflect on ways that they can be grouped. For example, perhaps a tumbler and a mug each belong to a Cup class. Or, maybe a corgi belongs a Dog class, and a sunflower belongs to a Flower class.
Task Feedback:
Fantastic! Grouping objects based on some criteria is critical when working with classes.
Object-Oriented Programming
To recap the above, objects in JavaScript can represent real-life things. That is, objects can have properties to represent attributes or characteristics, as well as methods to represent actions that can be performed. Using the analogy of spoken language, you can think of objects as nouns, such as a "dog" or a "car." Values of properties are adjectives, such as "blue." Methods, then, are the verbs, such as "bark" or "drive."
In the next section, we'll take a dive into object-oriented JavaScript, beginning with constructor functions. If you've had experience with object-oriented programming in other languages (e.g., Ruby, Python, etc.), you may be surprised to learn that JavaScript does not have a traditional class system (namely, one where the compiler does a lot of organizing out of sight). Instead, the class system is built directly using functions and objects. So rather than using a special class syntax, in JavaScript we define constructor functions. Let's dive right in!